<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="utf-8">
    <meta name="csrf-token" content="{{ csrf_token() }}">
    <link rel="stylesheet" href="/shop/style/css/ch-ui.admin.css">
    <link rel="stylesheet" href="/houtai/layui/css/layui.css">
    <script src="/houtai/layui/layui.js"></script>
    <link rel="stylesheet" href="/shop/style/font/css/font-awesome.min.css">
    <script type="text/javascript" src='/houtai/layui/jquery-3.2.1.js'></script>
</head>
<body>
    <!--面包屑导航 开始-->
    <div class="crumb_warp">
        <!--<i class="fa fa-bell"></i> 欢迎使用登陆网站后台，建站的首选工具。-->
        <i class="fa fa-home"></i> <a href="#">首页</a> &raquo; <a href="#">商品管理</a> &raquo; 编辑商品
    </div>
    <!--面包屑导航 结束-->

    <!--结果集标题与导航组件 开始-->
    <div class="result_wrap">
        <div class="result_title">
            <h3>快捷操作</h3>
        </div>
        <div class="result_content">
            <div class="short_wrap">
                <a href=""><i class="fa fa-plus"></i>编辑商品类别</a>
            </div>
        </div>
    </div>
    <!--结果集标题与导航组件 结束-->
    
    <div class="result_wrap">
        <table class="add_tab">
            <tbody>
            <tr>
                <th><i class="require">*</i>商品类别：</th>
                <td>
                    @if($list->isEmpty())
                    @else
                        @foreach($list as $vo)
                            <button class="layui-btn layui-btn-primary layui-btn-sm" title="点击删除" onclick="del_cy('{{$vo['tid']}}','{{$vo['gid']}}')">{{$vo['name']}}</button>
                    @endforeach
                @endif
                <!-- <p>请输入商品名</p> -->
                </td>
            </tr>
        <form action="javascript:void(0);" method="post" id="login_form">
                    <tr>
                        <th><i class="require">*</i>类型：</th>
                        <td>
                            <select name="tid">
                                @foreach($type as $fvo)
                                    {{--<option value="{{$k['id']}}">{{$k['name']}}</option>--}}
                                    <option value="{{$fvo->id}}" @if($fvo->is_exit == 1)disabled="disabled" @endif><?php echo str_repeat("&nbsp;",substr_count($fvo->path,',')*3);?>|--{{$fvo->name}}</option>
                                @endforeach


                            </select>
                        </td>
                    </tr>
                    <input type="hidden" name="id" value="{{$gid}}">
                    <tr>
                        <th></th>
                        <td>
                            <input type="submit" value="提交">
                            <input type="button" class="back" onclick="history.go(-1)" value="返回">
                        </td>
                    </tr>
                </tbody>
            </table>
        </form>
    </div>
    <script>
        $(function(){
            $.ajaxSetup({
                headers: {
                    'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
                }
            });
            layui.use('layer', function() {
                $("#login_form").submit(function(){
                    var tid = $("select[name=tid]").val();
                    var gid = $("input[name=id]").val();

                    $.ajax({
                        url: "/shop/good/type_insert",
                        type: 'post',
                        async: false,
                        data: {'tid':tid,'gid':gid},
                        success: function (data) {
                            layer.msg(data['msg']);
                            location.href = '/shop/good/type?id='+gid;
                        },
                    });

                });
            });
        })
        function del_cy(tid,gid){
            layui.use('layer', function() {
                layer.confirm('确定删除?', {icon: 3, title: '提示'}, function (index) {
                    $.ajax({
                        url:'/shop/good/type_del',
                        type:'post',
                        async:false,
                        data:{tid:tid,gid:gid},
                        success:function(msg){
                            layer.msg(msg['msg']);
                            location.href=location.href;
                        },
                    })
                });
            });
        }
    </script>
</body>
</html>